package com.example.droolstool.service;

import com.example.droolstool.module.Message;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.springframework.stereotype.Service;

import javax.xml.ws.ServiceMode;

/**
 * @Author 赵云龙
 * @Date 2020/6/6
 * @Description TODO
 */
@Service
public class DroolsServiceImpl {



    public String fireRule(){
        //load up the knowledge base
        KieServices kieServices = KieServices.get();
        KieContainer kieContainer = kieServices.getKieClasspathContainer();
       KieSession kieSession = kieContainer.newKieSession("ksession-rules");
        Message message = new Message();
        message.setMessage("Hello World");
        message.setStatus(Message.HELLO);

        kieSession.insert(message);
        kieSession.fireAllRules();
        kieSession.dispose();
        return message.getMessage();
    }

}
